package com.mytaobao.main.weitao;

import android.content.Context;
import android.graphics.Typeface;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.baseproject.util.LogUtils;
import com.mytaobao.R;

/**
 * Created by hp on 2017/4/14.
 */

public class WeiTaoTabCustomView extends LinearLayout{

    private final AppBarLayout mAppBarLayout;
    private final WeiTaoAppBarLayoutBehavior weiTaoAppBarLayoutBehavior;
    private Typeface font;
    TextView textView;
    ImageView imageView;

    public WeiTaoTabCustomView(Context context, AppBarLayout appBarLayout) {
        super(context);

        mAppBarLayout = appBarLayout;
        weiTaoAppBarLayoutBehavior = (WeiTaoAppBarLayoutBehavior) ((CoordinatorLayout.LayoutParams)mAppBarLayout.getLayoutParams()).getBehavior();
        View view = LayoutInflater.from(context).inflate(R.layout.weitao_tab_view, this, true);
        setOrientation(VERTICAL);
        LinearLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        setLayoutParams(layoutParams);
        setGravity(Gravity.CENTER_VERTICAL);

        textView = (TextView) view.findViewById(R.id.tv_weitao);
        imageView = (ImageView) view.findViewById(R.id.iv_weitao);

    }

    public void setText(String text) {
        textView.setText(text);
    }

    public void setIcon(int Rid) {
        imageView.setImageResource(Rid);
    }

    public TextView getTextView() {
        return textView;
    }

    public ImageView getImageView() {
        return imageView;
    }

    @Override
    public void dispatchSetSelected(boolean selected) {
        LogUtils.d("[WeiTaoTabCustomView] text = " + this.getTextView().getText() + " dispatchSetSelected = " + selected);
        super.dispatchSetSelected(selected);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);
    }
}
